package cn.wolfcode.shop.common;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

public class CommonControllerAdvice {

    @ExceptionHandler(BusinessException.class)
    @ResponseBody
    public Result handlerBusinessException(BusinessException ex){

        return Result.error(ex.getCodeMsg());
    }

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result handlerBusinessException(Exception ex){
        ex.printStackTrace();
        return Result.defalutError();
    }
}
